//
//  ViewController.m
//  7. Alerts
//
//  Created by iD Student on 7/8/13.
//  Copyright (c) 2013 iD Student. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    pastGenerations = [[NSMutableArray alloc]init];
    pastGenerationsString = [[NSString alloc]initWithFormat:@""];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(IBAction)generateNumber:(int)number1 getNumber2:(int)number2
{
    int randomNumber = arc4random() % ([number2Field.text intValue] - [number1Field.text intValue]) + [number1Field.text intValue];
    [number1Field resignFirstResponder];
    [number2Field resignFirstResponder];
    [pastGenerations addObject:[NSString stringWithFormat:@"%d", randomNumber]];

    if(pastGenerations.count == 1)
    {
    pastGenerationsString = [NSString stringWithFormat:@"%d", randomNumber];
    }
    else
    {
   [pastGenerationsView setText: pastGenerationsString];
    }
    //for (int i = 0; i < pastGenerations.count; i++) {
    //
    //}
    
}


@end
